#!/usr/bin/env bash
# 将执行目录移动到 当前文件所在目录
cd `dirname $0`

# 检查配置文件
if [ ! -f 'proxy.conf' ];then
    cp proxy.conf.example proxy.conf
fi
source ./proxy.conf

CONTAINER_NAME="http-proxy";

docker pull dannydirect/tinyproxy
docker stop ${CONTAINER_NAME}
docker rm ${CONTAINER_NAME}
docker run -d \
-p 6666:8888 dannydirect/tinyproxy:latest ANY
docker run -d \
    -p ${PROXY_PORT}:8888 \
    --name "${CONTAINER_NAME}" \
    --restart=on-failure:10 \
    dannydirect/tinyproxy \
    ANY

docker start "${CONTAINER_NAME}"

cd -
